package com.one.servlet;

import com.one.pojo.Cart;
import com.one.service.cartService;
import com.one.service.impl.cartServiceImpl;

import javax.servlet.RequestDispatcher;
import javax.servlet.Servlet;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * @author LJ
 * @create 2022-04-25-21:46
 */
@WebServlet("/goCare")
public class goCareServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("1");
        cartService service=new cartServiceImpl();
        List<Cart> carts = service.allCart();
        carts.forEach(System.out::println);
        req.setAttribute("carts", carts);
        req.getRequestDispatcher("gocart.jsp").forward(req, resp);
    }
}
